﻿<UserControl x:Class="SQLDeploymentBuilder.UI.Controls.Connections.Editors.SQLConnectionEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:SQLDeploymentBuilder.UI.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="350" d:DesignWidth="300">
    <UserControl.Resources>
        <converters:ReverseBoolean x:Key="boolReverse"/>
    </UserControl.Resources>
    <Grid Margin="4">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <TextBlock  Grid.Column="0" Grid.Row="0" Margin="4"
            Text="Connection Name:"/>
        
        <TextBox Grid.Column="0" Grid.Row="1" Margin="4"
                 Text="{Binding Path=Name, Mode=TwoWay}"/>

        <TextBlock  Grid.Column="0" Grid.Row="2" Margin="4"
            Text="SQL Server:"/>

        <TextBox Grid.Column="0" Grid.Row="3" Margin="4"
                 Text="{Binding Path=SQLServer, Mode=TwoWay}"/>
        
        <GroupBox Grid.Column="0" Grid.Row="4"
            Header="Logon to server">
            <GroupBox.Content>
                <Grid Margin="4,8,4,4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    
                    <RadioButton Grid.Row="0" Grid.Column="0" Margin="4"
                        Content="Use Windows Authentication" 
                        Checked="{Binding Path=UseTrustedConnection, 
                            Mode=TwoWay, NotifyOnSourceUpdated=True,
                            NotifyOnTargetUpdated=True}"/>
                    <RadioButton Grid.Row="1" Grid.Column="0" Margin="4"
                        Content="Use SQL Server Authentication" 
                        Checked="{Binding Path=UseTrustedConnection, Converter={StaticResource boolReverse},
                            Mode=TwoWay, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True}"/>
                
                    <Grid Grid.Column="0" Grid.Row="2" Margin="24,4,0,4">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        
                        <TextBlock Grid.Row="0" Grid.Column="0" Margin="4"
                                   Text="User name:"
                                   IsEnabled="{Binding Path=UseTrustedConnection, Converter={StaticResource boolReverse},
                                        NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, Mode=TwoWay}"/>
                        <TextBox Grid.Row="0" Grid.Column="1" Margin="4"
                                 Text="{Binding Path=SQLUser}"
                                 IsEnabled="{Binding Path=UseTrustedConnection, Converter={StaticResource boolReverse},
                                        NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, Mode=TwoWay}"/>

                        <TextBlock Grid.Row="1" Grid.Column="0" Margin="4"
                                   Text="Password:"
                                   IsEnabled="{Binding Path=UseTrustedConnection, Converter={StaticResource boolReverse},
                                        NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, Mode=TwoWay}"/>
                        <TextBox Grid.Row="1" Grid.Column="1" Margin="4"
                                 Text="{Binding Path=SQLUserPassword}"
                                 IsEnabled="{Binding Path=UseTrustedConnection, Converter={StaticResource boolReverse},
                                        NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, Mode=TwoWay}"/>
                        
                        
                    </Grid>
                </Grid>
            </GroupBox.Content>
        </GroupBox>
        
        <TextBlock Grid.Column="0" Grid.Row="5" Margin="4"
                   Text="Database:"/>
        <TextBox Grid.Column="0" Grid.Row="6" Margin="4"
                 Text="{Binding Path=Database}"/>

        <StackPanel Grid.Column="0" Grid.Row="7" Margin="4" Orientation="Vertical">
            <Button Content="Test Connection" HorizontalAlignment="Left"/>
        </StackPanel>
            
    </Grid>
</UserControl>
